package cn.cnsuh.剑指offer.q03_数组中重复的数字;

import java.util.HashMap;
import java.util.Map;

/**
 * created by mzk on 2020/07/25
 */
public class Main {

    public static void main(String[] args) {
        int[] arr = {1,2,3,4,1};
        System.out.println(findRepeatNumber(arr));
    }
    static int findRepeatNumber(int[] nums) {
        Map<Integer,Integer> map = new HashMap<>();
        for(int i = 0 ; i < nums.length;i++){
            if(map.containsKey(nums[i])){
                return nums[i];
            } else{
                map.put(nums[i],1);
            }
        }
        return 0;
    }
}
